# Contributor: rubicon <rubicon@mailo.com>
# Maintainer: Celeste <cielesti@protonmail.com>
maintainer="Celeste <cielesti@protonmail.com>"
pkgname=txr
pkgver=296
pkgrel=1
pkgdesc="Programming language for convenient data munging"
url="https://www.nongnu.org/txr/"
# s390x: ftbfs (struct jmp in unwind.h not ported)
# riscv64: tests/006/freeform-5.txr segfaults
arch="all !s390x !riscv64"
license="BSD-2-Clause"
makedepends="libffi-dev zlib-dev"
subpackages="$pkgname-doc $pkgname-vim::noarch"
source="https://www.kylheku.com/cgit/txr/snapshot/txr-$pkgver.tar.gz
	fix-loongarch64-warning.patch
	"

build() {
	./configure --prefix=/usr
	make
}

check() {
	case "$CARCH" in
	aarch64)
		msg "Disabling IPv6 test for aarch64 in 014/dgram-stream.tl"
		sed -i 's/,\*maybe-ipv6//' tests/014/dgram-stream.tl
		;;
	x86)
		msg "Disabling 012/cont.tl and 012/compile.tl tests on x86"
		rm -v tests/012/cont.tl tests/012/compile.tl
		;;
	esac

	make tests
}

package() {
	make DESTDIR="$pkgdir" install

	install -Dvm644 LICENSE METALICENSE \
		-t "$pkgdir"/usr/share/licenses/$pkgname/
}

vim() {
	pkgdesc="Vim syntax for $pkgname"
	depends=
	install_if="$pkgname=$pkgver-r$pkgrel vim"

	install -Dvm644 "$builddir"/*.vim \
		-t "$subpkgdir"/usr/share/vim/vimfiles/syntax/
}

sha512sums="
ac6e072d578ec114fb0aee9dbbb338e6debe1efee675edd7b3d49777a88ca2847683b30b9a2f3d16e7a7fc79ad80bd8bbc20d5a6b784dd7aad542b70f52a9849  txr-296.tar.gz
e855227609ae78485b50778ac8aa002f16572a79247faedd9f6c2686bce262d1e37d9e9a38a0f4d5592b9456e9a0e8d30ce20b238131f04849ca5aa71f1eaed1  fix-loongarch64-warning.patch
"
